package com.maysham.tripod.dao;

import com.maysham.tripod.model.CodeBase;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

@Repository
public class CodeBaseDao {
    @Resource
    private MongoTemplate template;

    public CodeBase findById(String codeBaseId){
        return template.findOne(Query.query(Criteria.where("id").is(codeBaseId).and("deleted").is(false)), CodeBase.class);
    }

    public CodeBase save(CodeBase codeBase) {
        return template.save(codeBase);
    }
}
